{% extends 'admin/manager.html' %}

{% block app_content %}
<div class="container mb-4"></div>
<h1 class="display-6" align="center">学生选课管理</h1>
<div class="container mb-4"></div>
<form action="/add_course_select" method="POST">
    <div class="form-row">
      <div class="col">
        <input type="number" name="CourseNum" class="form-control" placeholder="课程号" required>
      </div>
      <div class="col">
          <input type="number" name="TeacherNum" class="form-control" placeholder="教师工号" required>
        </div>
      <div class="col">
        <input type="number" name="StudentNum" class="form-control" placeholder="学生学号" required>
      </div>
      <div class="col">
      <button type="submit" class="btn btn-block btn-success mb-2">手动签课</button>
      </div>
    </div>
  </form>
  <hr>
  <form action="/drop_course_select" method="POST">
    <div class="form-row">
      <div class="col">
        <input type="number" name="CourseNum" class="form-control" placeholder="课程号" required>
      </div>
      <div class="col">
          <input type="number" name="TeacherNum" class="form-control" placeholder="教师工号" required>
        </div>
      <div class="col">
        <input type="number" name="StudentNum" class="form-control" placeholder="学生学号" required>
      </div>
      <div class="col">
      <button type="submit" class="btn btn-block btn-danger mb-2">手动退课</button>
      </div>
    </div>
  </form>
  <hr>
  <div class="container mb-4"></div>
    <table class="table table-striped table-hover">
            <thead class="thead-dark">
        <tr>
            <th class="lead">课程号</th>
            <th class="lead">课程名</th>
            <th class="lead">教师号</th>
            <th class="lead">教师名</th>
            <th class="lead">课程容量</th>
            <th class="lead">已选人数</th>
            <th class="lead">容量管理</th>
            <th class="lead">课程管理</th>
        </tr>
            </thead>
            <tbody>
        {% if tables %}
        {% for table in tables %}
        <tr>
           <td class="lead">{{ table.CourseNum }}</td>
           <td class="lead">{{ table.CourseName }}</td>
           <td class="lead">{{ table.TeacherNum }}</td>
           <td class="lead">{{ table.TeacherName }}</td>
           <td class="lead">{{ table.CourseCapacity }}</td>
           <td class="lead">{{ table.CourseStudents }}</td>
           <td class="lead">
              <a href="{{ url_for('change_course_capacity', CourseNum=table.CourseNum, TeacherNum=table.TeacherNum, add_or_sub='add') }}" class="btn btn-success btn-sm" role="button">扩容</a>
              <a href="{{ url_for('change_course_capacity', CourseNum=table.CourseNum, TeacherNum=table.TeacherNum, add_or_sub='sub') }}" class="btn btn-warning btn-sm" role="button">缩容</a>
           </td>
           <td class="lead">
                <a href="{{ url_for('course_teacher_delete', CourseNum=table.CourseNum, TeacherNum=table.TeacherNum) }}" class="btn btn-outline-danger btn-sm" role="button">删除开设课程</a>
           </td>
        </tr>
        {% endfor %}
        {% endif %}
    </tbody>
    </table>
{% endblock %}